package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.Result;
import com.atguigu.srb.core.pojo.UserInfoQuery;
import com.atguigu.srb.core.pojo.entity.UserInfo;
import com.atguigu.srb.core.service.UserInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author ZLHao
 * @since 2021-07-12
 */
@Api(tags = "会员列表管理")
@RestController
@Slf4j
@RequestMapping("/admin/core/userInfo")

public class AdminUserInfoController {

    @Autowired
    private  UserInfoService  userInfoService;

    @ApiOperation("获取分页列表")
    @GetMapping("/list/{page}/{limit}")
    public Result list(
            @ApiParam("当前页数")
            @PathVariable Long page,

            @ApiParam("显示的行数")
            @PathVariable Long limit,

            @ApiParam("查询条件")
             UserInfoQuery userInfoQuery
            ){

        Page<UserInfo> userInfoPage = new Page<>(page,limit);
        IPage<UserInfo> pageModel  =  userInfoService.listPage(userInfoPage,userInfoQuery);
//        IPage<UserInfo> page1 = userInfoService.page();
        return Result.ok().data("pageModel",pageModel);

    }



    @ApiOperation("锁定用户")
    @PutMapping("/lock/{id}/{status}")
    public Result lock(
            @ApiParam("用户ID")
            @PathVariable("id") Long  id ,
            @ApiParam("修改状态")
            @PathVariable("status") Integer status){

        userInfoService.lock(id,status);
        return Result.ok().message(status==0?"锁定成功":"解锁成功");

    }

}

